#!/usr/bin/env bash

if [ ! -d "$HOME/bin" ] ; then
    mkdir $HOME/bin

    if [ -f $HOME/.profile ]; then
        . $HOME/.profile

        if [[ ":$PATH:" != *":$HOME/bin:"* ]]; then
            echo -e '\nPATH="$HOME/bin:$PATH"' >> $HOME/.profile
        fi
    fi
fi

# test if curl/wget is installed
if hash curl 2>&- ; then
    CMD="curl -s -o"
elif hash wget 2>&- ; then
    CMD="wget -q -O"
else
   echo "You need to have curl or wget installed."
   exit 1
fi

$CMD $HOME/bin/modman https://raw.github.com/colinmollenhour/modman/master/modman

chmod +x $HOME/bin/modman

echo "Done. Modman installed in $HOME/bin/modman"
